
import ChuKuDanInfo from "./chuKuDanInfo.vue";
import {  ElTableColumn, ElTable, ElDialog } from 'element-plus';
import { XieYiYiYuanChuKuOutput } from "/@/api/inv/invXieYiYiYuanChuKu";

/**
 * 调用获取出库单信息
 * @returns 
 */
export default function useChuKuDanInfo () {
  let instance: any;

  if(!instance) {
    // 将api放在后面，即以 组件的props 的形式传入
    const app = createApp(ChuKuDanInfo);
    app.use(ElTableColumn).use(ElTable).use(ElDialog);
    const container = document.createElement("div");
    instance = app.mount(container);
    document.body.appendChild(container);
  }
  instance.open()
  return new Promise((resolve, reject) => {
    // 确认框回调
    const confirmCallback = (select: XieYiYiYuanChuKuOutput) => {
      resolve(select)
    }
    // 弹框消失前销毁组件
    const destory = () => {
      if (instance) {
        instance.$el.parentNode.remove();
        instance = null;
      }
    }
    instance.config = { ...instance.config,  confirmCallback, destory}
  })
}